<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>

	<title>教学管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		//查看下发课程体系
		function viewCourseSystem(id){
			$.ajax({
				type: "POST",
				url: "${ctx}/teach/teachDistribute/viewCourseSystem",
				data: {
					ids:id
				},
				success: function (CourseSystem) {
					for (var i = 0; i < CourseSystem.length; i++) {
						$("#viewCourseSystem").append("<li><a href='${ctx}/resource/resourceCourse/viewCourseList?courseSystemId="+CourseSystem[i].courseSystemId+"'>" + CourseSystem[i].courseSystemName + "</a></li>");
					}
				},
				error:function(){
					console.info("error");
				}
			});
			$.jBox($("#viewCourseSystemBox").html(), {title:"查看课程体系", buttons:{"关闭":true}, submit: function(){}});
		}
		//查看下发CTF题目集
		function viewCTFSet(id){
			$.ajax({
				type: "POST",
				url: "${ctx}/teach/teachDistribute/viewCTFSet",
				data: {
					ids:id
				},
				success: function (CTFSet) {
					for (var i = 0; i < CTFSet.length; i++) {
						$("#viewCTFSet").append("<li><a href='${ctx}/resource/resourceCtfSubject/viewCtfSubjectList?ctfSetId="+CTFSet[i].ctfSetId+"'>" + CTFSet[i].ctfSetName + "</a></li>");
					}
				},
				error:function(){
					console.info("error");
				}
			});
			$.jBox($("#viewCTFSetBox").html(), {title:"查看CTF题目集", buttons:{"关闭":true}, submit: function(){}});
		}
		//查看下发试卷
		function viewPaperName(id){
			$.ajax({
				type: "POST",
				url: "${ctx}/teach/teachDistribute/viewPaperName",
				data: {
					ids:id
				},
				success: function (PaperName) {
					for (var i = 0; i < PaperName.length; i++) {
						$("#viewPaperName").append("<li>" + PaperName[i].paperName + "</li>");
					}
				},
				error:function(){
					console.info("error");
				}
			});
			$.jBox($("#viewPaperNameBox").html(), {title:"查看下发试卷", buttons:{"关闭":true}, submit: function(){}});
		}
		//查看下发对象
		function viewTarget(id){
			$.ajax({
				type: "POST",
				url: "${ctx}/teach/teachDistribute/viewTargetName",
				data: {
					ids:id
				},
				success: function (TargetName) {
					for (var i = 0; i < TargetName.length; i++) {
						$("#viewTargetName").append("<li>" + TargetName[i].targetName + "</li>");
					}
				},
				error:function(){
					console.info("error");
				}
			});
			$.jBox($("#viewTargetBox").html(), {title:"查看下发对象", buttons:{"关闭":true}, submit: function(){}});
		}
	</script>
	<script type="text/template" id="viewTargetBox">
		<div>
			<ul id="viewTargetName">
			</ul>
		</div>
	</script>
	<script type="text/template" id="viewCTFSetBox">
		<div>
			<ul id="viewCTFSet">
			</ul>
		</div>
	</script>
	<script type="text/template" id="viewPaperNameBox">
		<div>
			<ul id="viewPaperName">
			</ul>
		</div>
	</script>
	<script type="text/template" id="viewCourseSystemBox">
		<div>
			<ul id="viewCourseSystem">
			</ul>
		</div>
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/teach/teachDistribute/">教学管理列表</a></li>
		<shiro:hasPermission name="teach:teachDistribute:edit"><li><a href="${ctx}/teach/teachDistribute/form">下发添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="teachDistribute" action="${ctx}/teach/teachDistribute/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li style="margin-right: 20px"><label>下发名称：</label>
				<%--<form:input path="distributeName" htmlEscape="false" maxlength="100" class="input-medium"/>--%>
				<input id="distributeName" name="distributeName" value="${teachDistribute.distributeName}" class="input-medium" type="text">
			</li>
			<li>下发时间范围：&nbsp;<input id="beginDate" name="beginDate" type="text" readonly="readonly" maxlength="40" class="input-mini Wdate beginDateInput" style="width: 150px"
													 value="<fmt:formatDate value="${teachDistribute.beginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				&nbsp;--&nbsp;&nbsp;<input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="40" class="input-mini Wdate endDateInput" style="width: 150px"
																			value="<fmt:formatDate value="${teachDistribute.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li class="btns">&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>下发名称</th>
				<th>下发时间</th>
				<th>课程体系名称</th>
				<th>CTF题目集名称</th>
				<th>试卷名称</th>
				<th>下发对象</th>
				<shiro:hasPermission name="teach:teachDistribute:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="teachDistribute">
			<tr>
				<td>
					${teachDistribute.distributeName}
				</td>
				<td>
					<fmt:formatDate value="${teachDistribute.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<a href="javascript:viewCourseSystem('${teachDistribute.id}')" title="查看课程体系">查看课程体系</a>
				</td>
				<td>
					<a href="javascript:viewCTFSet('${teachDistribute.id}')" title="查看CTF题目集">查看CTF题目集</a>
				</td>
				<td>
					<a href="javascript:viewPaperName('${teachDistribute.id}')" title="查看试卷">查看试卷</a>
				</td>
				<td>
					<a href="javascript:viewTarget('${teachDistribute.id}')" title="查看下发对象">查看下发对象</a>
				</td>
				<shiro:hasPermission name="teach:teachDistribute:edit"><td>
    				<a href="${ctx}/teach/teachDistribute/form?id=${teachDistribute.id}">修改</a>
					<a href="${ctx}/teach/teachDistribute/delete?id=${teachDistribute.id}" onclick="return confirmx('确认要删除该次下发吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<script>
		<%--重置--%>
		var test=document.getElementById("search");
		test.onclick=function(){
			var beginDateInput=document.getElementsByClassName("beginDateInput")[0];
			var endDateInput=document.getElementsByClassName("endDateInput")[0];
			var distributeName=document.getElementById("distributeName");
			beginDateInput.value = null;
			endDateInput.value = null;
			distributeName.value = null;
		};
	</script>
</body>
</html>